package com.zhouxiaoge.json;

import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

import java.lang.reflect.Type;

/**
 * @author 周小哥  gqzmy@163.com 2022/8/14 11:20
 */

public class BooleanSerializer implements JsonSerializer<Boolean> {
    @Override
    public JsonElement serialize(Boolean src, Type typeOfSrc, JsonSerializationContext context) {
        return src ? new JsonPrimitive("活着") : new JsonPrimitive("死亡");
    }
}
